<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="UTF-8" />
    <title>Datetime - Locale</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0" />
    <link href="../../../../../css/ionic.bundle.css" rel="stylesheet" />
    <link href="../../../../../scripts/testing/styles.css" rel="stylesheet" />
    <script src="../../../../../scripts/testing/scripts.js"></script>
    <script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script>
    <style>
      .grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(250px, 1fr));
        grid-gap: 60px 20px;
      }

      h2 {
        font-size: 12px;
        font-weight: normal;

        color: #6f7378;

        margin-top: 10px;
        margin-left: 5px;
      }

      @media screen and (max-width: 800px) {
        .grid {
          grid-template-columns: 1fr;
          padding: 0;
        }
      }

      ion-datetime {
        box-shadow: 0px 16px 32px rgba(0, 0, 0, 0.25), 0px 8px 16px rgba(0, 0, 0, 0.25);
        border-radius: 8px;
      }
    </style>
  </head>

  <body>
    <ion-app>
      <ion-header translucent="true">
        <ion-toolbar>
          <ion-title>Datetime - Locale</ion-title>
        </ion-toolbar>
        <ion-toolbar>
          <select class="ion-margin-end" slot="end">
            <option value="en-US">en-US</option>
            <option value="es-ES">es-ES</option>
            <option value="ja-JP">ja-JP</option>
            <option value="ta-IN">ta-IN</option>
          </select>
        </ion-toolbar>
      </ion-header>
      <ion-content class="ion-padding">
        <div class="grid">
          <div class="grid-item">
            <h2>Default (AM)</h2>
            <ion-datetime
              id="am"
              show-default-title="true"
              show-default-buttons="true"
              locale="en-US"
              value="2022-04-19T04:20:00"
            ></ion-datetime>
          </div>
          <div class="grid-item">
            <h2>Default (PM)</h2>
            <ion-datetime
              id="pm"
              show-default-title="true"
              show-default-buttons="true"
              locale="en-US"
              value="2022-04-19T14:20:00"
            ></ion-datetime>
          </div>
        </div>
      </ion-content>
    </ion-app>
    <script>
      const select = document.querySelector('select');
      const datetimes = document.querySelectorAll('ion-datetime');

      select.addEventListener('change', (ev) => {
        const locale = ev.target.value;
        datetimes.forEach((datetime) => {
          datetime.locale = locale;
        });
      });
    </script>
  </body>
</html>
